
package com.ssm.service.impl;

import com.ssm.dao.TeacherMapper;
import com.ssm.dao.UmTeacherMapper;
import com.ssm.entity.Teacher;
import com.ssm.entity.UmTeacher;
import com.ssm.entity.UmTeacherExample;
import com.ssm.service.TeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("teacherService")
public class TeacherServiceImpl implements TeacherService {

    @Resource(name = "teacherMapper")
    private TeacherMapper teacherMapper;
    @Resource(name = "umTeacherMapper")
    private UmTeacherMapper umTeacherMapper;
    @Override
    public Teacher login(String username, String password) {
        return teacherMapper.selectByLogin(username,password);
    }

    @Override
    public List<UmTeacher> listAllTeacher() {
        return umTeacherMapper.selectByExample(new UmTeacherExample());
    }

    @Override
    public Integer createTeacher(UmTeacher umTeacher) {
        return umTeacherMapper.insertSelective(umTeacher);
    }

    @Override
    public Integer update(UmTeacher umTeacher) {
        return umTeacherMapper.updateByPrimaryKeySelective(umTeacher);
    }

    @Override
    public Integer deleteTeacher(int id) {
        return umTeacherMapper.deleteByPrimaryKey(id);
    }

    @Override
    public UmTeacher getUmTeacher(int id) {
        return umTeacherMapper.selectByPrimaryKey(id);
    }
}
